< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03120401.xhp

(section: instr) (bookmark: bm_id3155934)
InStr function

InStr; 関数

InStr Function [Runtime]
InStr 関数 [実行時](hd_id3155934.1)

Returns the position of a string within another string.
2 つの文字列の一方が、他方の文字列中のどの位置にあるかを返します。(par_id3153990.2)

(/section: instr)

The Instr function returns the position at which the match was found. If the string was not found, the function returns 0.
Instr 関数からは、文字列の一致した位置が返されます。一致する部分がない場合は、0 が返されます。(par_id3147303.3)

Syntax:
構文:(hd_id3145090.4)

InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare])
InStr ([Start As Integer,] Text1 As String, Text2 As String[, Compare])(par_id3146957.5)

Return value:
戻り値:(hd_id3148538.6)

Integer
整数(par_id3149763.7)

Parameters:
パラメータ:(hd_id3148473.8)

Start: A numeric expression that marks the position in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the first character of the string. The maximum allowed value is 65535.
Start: 検索対象の文字列のどの位置から検索文字列のマッチングを開始するかを指定します。このパラメータ指定を省略すると、文字列の最初の文字から検索が始まります。使用できる最大値は 65535 です。(par_id3153126.9)

Text1: The string expression that you want to search.
Text1: 検索対象とする文字列の表式。(par_id3145609.10)

Text2: The string expression that you want to search for.
Text2: 検索文字列の表式。(par_id3147559.11)

Compare: Optional numeric expression that defines the type of comparison. The value of this parameter can be 0 or 1. The default value of 1 specifies a text comparison that is not case-sensitive. The value of 0 specifies a binary comparison that is case-sensitive.
Compare:比較の種類を指定する数値表式 (省略可)。このパラメータの値には 0 または 1 を指定できます。デフォルト値は 1 は、大文字と小文字の区別がないテキスト比較を指定します。値 0 は、大文字と小文字を区別するバイナリ比較を指定します。(par_id3154758.12)

To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted.
最初のパラメータを省略した場合に Compare パラメータを指定すると、実行時エラーが発生することがあります。(par_id3153361.13)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

Example:
例:(hd_id3154366.14)

Sub ExamplePosition
Sub ExamplePosition(par_id3154217.15)

Dim sInput As String
Dim sInput As String(par_id3154685.16)

Dim iPos as Integer
Dim iPos as Integer(par_id3151042.17)

sInput = "Office"
sInput = "Star Suite"(par_id3144760.19)

iPos = Instr(sInput,"c")
iPos = Instr(sInput,"v")(par_id3154125.20)

print iPos
print iPos(par_id3145173.21)

end sub
end sub(par_id3145786.22)


< Prev / Next >